<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改学生信息</title>
</head>
<body>
<div>
    <h3>修改学生信息</h3>
<span id="sid">学号：</span><br>
    <span>姓名：</span><input type="text" id="sname"><br>
    <span>性别：</span>
    <input  type="radio" name="ssex" id="nan" value="男">男
    <input  type="radio" name="ssex" id="nv" value="女">女<br>
    <span>生日：</span><input type="date" id="birth"><br>
    <button id="btn">确认修改</button>
</div>
<script src="/js/jquery-3.6.0.js"></script>
<script>
    $("#btn").click(function () {
        var sname=$("#sname").val();
        var ssex=$('input:radio:checked').val();
        var birth=$("#birth").val();
        $.ajax({
            url:"/admin/upStu",
            type:"post",
            data:"sid="+sid+"&sname="+sname+"&ssex="+ssex+"&birth="+birth,
            success:function (data){
                if (data==1){
                    alert("修改成功！");
                }else {
                    alert("修改失败！")
                }
                location.href="/admin/showAll.html";
            }
        })

    })

    var sid=sessionStorage.getItem("sid");
    console.log(sid)
    $.ajax({
        url:"/admin/huitian",
        type:"post",
        data:"sid="+sid,
        success:function (data){
            console.log(data)
            $("#sid").append(sid);
            $("#sname").val(data.sname);
            if (data.ssex=="女"){
                $("#nv").attr("checked","checked");
            }else {
                $("#nan").attr("checked","checked");
            }
            // $("input:radio[value="+data.ssex+"]").attr("checked",true);
            $("#birth").attr("value",""+data.birth+"")
        }
    })


</script>

</body>
</html>